package servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MakeOrder extends Dispatcher {
    public String getServletInfo(){
        return "Make order servlet";
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        ServletContext ctx = getServletContext();
        //if (request.getParameter("add")!=null){
            String status = request.getParameter("status");

            Integer itemNumber = 0;
            String itemId = request.getParameter("items[" + itemNumber + "][id]");
            while(itemId != null)
            {
                Order newOrder = new Order();

                /*newOrder.setItemid(itemId);
                newOrder.setPriority("");
                newOrder.setItemcount(request.getParameter("items[" + itemNumber + "][qty]"));
                newOrder.setStatus(status);     */

                OrderList.addOrder(newOrder);

                itemNumber++;
                itemId = request.getParameter("items[" + itemNumber + "][id]");
            }

            /*Order newOrder = new Order();

            newOrder.setItemid("");
            newOrder.setItemcount(items);
            newOrder.setStatus(status);
            newOrder.setPriority("");

            ctx.setAttribute("order", newOrder); */
           /* boolean res = OrderList.addOrder(newOrder); */
            /*if (res) {
                this.forward("/successAddedOrder.jsp", request, response);
            } else {
                this.forward("/successAddedOrder.jsp", request, response);
            }     */
        //} else if (request.getParameter("cancel")!=null){
        //    this.forward("/NewOrder.html", request, response);
        //}
    }
}